package com.lysj.merchant.merchant.feignImpl;

import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.lysj.admin.common.merchant.domain.WxConfigVo;
import com.lysj.admin.common.merchant.feign.WxConfigServiceFeign;
import com.lysj.merchant.merchant.domain.WxPayConfig;
import com.lysj.merchant.merchant.repository.WxpayConfigRepository;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ Author ：drj.
 * @ Date  ：Created in 11:33 2019/3/21
 * @ Description:
 **/
@RestController
public class WxpayConfigFeifnImpl implements WxConfigServiceFeign {

    @Resource
    private WxpayConfigRepository wxpayConfigRepository;


    @Override
    public Map<String, WxConfigVo> allWxpayConfig() {

        Map<String, WxConfigVo> map = new HashMap<>();
        List<WxPayConfig> wxPayConfigList = wxpayConfigRepository.findAll();
        for (WxPayConfig wxPayConfig : wxPayConfigList) {
            WxConfigVo wxConfigVo = new WxConfigVo();
            BeanUtil.copyProperties(wxPayConfig, wxConfigVo);
            map.put(wxPayConfig.getStoreId(), wxConfigVo);
        }
        return map;
    }

    @Override
    public WxConfigVo getStoreWxpayConfig(String storeId) {

        WxPayConfig wxPayConfig = wxpayConfigRepository.findByStoreId(storeId);

        WxConfigVo wxConfigVo = new WxConfigVo();

        BeanUtil.copyProperties(wxPayConfig,wxConfigVo);

        return wxConfigVo;
    }


}
